home *** CD-ROM | disk | FTP | other *** search
- Path: colossus.holonet.net!mitch
- From: mitch@news.mdli.com (Mitch Miller)
- Newsgroups: comp.lang.c
- Subject: Pointer-to-Double as Function Arg
- Date: 16 Jan 1996 05:17:08 GMT
- Organization: HoloNet National Internet Access System: 510-704-1058/modem
- Message-ID: <4dfccl$j5h@colossus.holonet.net>
- NNTP-Posting-Host: jubal.mdli.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- I'm having a problem with a function that takes a
- couple of pointer-to-double arguments, initializes then
- and assigns values to them in an array style:
-
- Function is something like:
-
- int GetValue( long iDim, double * Values1, double *
- Values2 )
- {
- int iter;
- Values1 = (double *) malloc( iDim * sizeof( double ));
- if (Values1 == NULL )
- ....
- Values2 = (double *) malloc( iDim * sizeof( double ));
- if (Values2 == NULL )
- ...
-
- for (iter=1; iter<iDim; iter++)
- {
- Values1[iter] = ...;
- Values2[iter] = ...;
-
- }
-
- return 1;
- }
-
- Call from main:
-
- double * Ptr1;
- double * Ptr2;
-
- if (!GetValue( iSize, Ptr1, Ptr2 ) )....
-
-
- When I look at the values of Values1 and Values2 in GetValue, they have
- the correct values.
-
- However, back in main, they have NULL values.
-
- If I make Ptr1 and Ptr2 global variables so that they are not included
- in the function calls, the code works fine.
-
- I've checked the FAQs, but couldn't find anything quite like this.
-
- Thanks in advance...
-